<%@page import="models.OrderProductModel"%>
<%@page import="models.OrderModel"%>
<%@page import="java.util.Map"%>
<%@page import="admin.data.CoordinaData"%>
<%@page import="java.util.TreeMap"%>
<%@page import="java.text.NumberFormat"%>
<%@page import="models.CoordinaModel"%>
<%@page import="models.RouteModel"%>
<%@page import="models.StaffModel"%>
<%@page import="java.util.List"%>
<%@page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	CoordinaModel coordinaModel = (CoordinaModel) request.getAttribute("coordinaModel");
	List<OrderModel> listOrder = (List<OrderModel>) request.getAttribute("listOrder");
	NumberFormat nf = NumberFormat.getInstance();
%>

<jsp:include page="/admin/layouts/header.jsp">
	<jsp:param name="language" value="1" />
</jsp:include>
<script type="text/javascript" src="/admin/js/return_coordina.js"></script>
<div class="maincontent noright">
	<div class="maincontentinner">
		<ul class="maintabmenu multipletabmenu">
			<li class="current"><a href="#">Giao nhận</a></li>
		</ul>
		<!--maintabmenu-->

		<div class="content">
			<div class="contenttitle">
				<h2 class="form">
					<span>Danh sách đơn hàng</span>
				</h2>
			</div>
			<table cellspacing="0" cellpadding="0" border="0" class="stdtable stdtablecb" id="list-order">		
                 <tbody>
                 	<tr>
                 	 <% for (int i = 0; i < listOrder.size(); i++) { %>                             
                 	 	<td class="center"><%=i+1 %></td>                 	 	
                 	 <% } %>
                 	 </tr>
                 </tbody>
	         </table>
	         <br />
	         <div class="order-accept" align="right">
				<button class="stdbtn btn_black" id="check">Chấp nhận</button>
			</div>
			<br/><br/><br/><br/>	
			
			<div id="form-detail-order">
				<div class="contenttitle">
					<h2 class="form">
						<span>Cập nhật LOC</span>
					</h2>
				</div>
				<!--contenttitle-->			
				<form method="post" action="#" class="stdform stdform2" id="edit_user_form">						
					<table cellspacing="0" cellpadding="0" border="0" class="stdtable stdtablecb" id="list-order-detail">				
	                    <colgroup>
		                        <col class="con0">
		                        <col class="con1">
		                        <col class="con0">
	                    </colgroup>
	                    <thead>
	                        <tr>
	                        	<th class="head0">STT</th>
	                            <th class="head1">Mã đơn hàng</th>
	                            <th class="head0">Phiếu / Sản phẩm</th>
	                            <th class="head1">Khách hàng</th>	        
	                            <th class="head0">Địa chỉ</th>                                               
	                            <th class="head1">Điện thoại</th>	
	                            <th class="head0">Số lượng</th>	                           
	                            <th class="head1">Đã giao</th>
	                            <th class="head0">Action</th>	                          
	                        </tr>
	                    </thead>
	                    <tbody>
	                      <% for (int i = 0; i < listOrder.size(); i++) { %>                             
		                  <tr>
		                      <td class="center"><%=i+1 %></td>
		                      <td align="center"><%=listOrder.get(i).getOrderId() %></td>
		                      <td align="left">
		                      	<%
		                    		List<String> listOrderProduct = listOrder.get(i).getListOrderProduct();
									for (String stringOrderProduct : listOrderProduct) {
										OrderProductModel orderProduct = new OrderProductModel();
										orderProduct.getValueFromString(stringOrderProduct);
										if(orderProduct.getQuantity()>0)
										{
											out.print("["+orderProduct.getProductId()+"]");
											out.print(orderProduct.getName()+" ["+orderProduct.getQuantity()+"]");
											out.print("<br \\/>");
										}
									}
		                    	%>
		                      </td>
	   	                      <td class="center"><%=listOrder.get(i).getShipName() %></td>
	   	                      <td align="left"><%=listOrder.get(i).getShipAddressFull() %></td>   
	   	                      <td class="center"><%=listOrder.get(i).getShipPhoneNumber() %></td>	           
	   	                      <td class="center">
	   	                      	<%=listOrder.get(i).getQuantity() %>
	   	                      </td>
	   	                      <td class="center">
	   	                      	<% 
	   	                     		for (String stringOrderProduct : listOrderProduct) {
		   	                     		OrderProductModel orderProduct = new OrderProductModel();
										orderProduct.getValueFromString(stringOrderProduct);
										if(orderProduct.getQuantity()>0)
										{
	   	                      	%>   	                     
	   	                      		<div class="change-number">
	   	                      			<span class="minus">-</span>
	   	                      			<span class="number"><%=orderProduct.getQuantity() %></span>
	   	                      			<span class="plus">+</span>
	   	                      			<span class="max hidden"><%=orderProduct.getQuantity() %></span>
	   	                      			<span class="status hidden">0</span>
	   	                      			<span class="money hidden"><%=listOrder.get(i).getUnitPrice()%></span>
	   	                      			<span class="store-return hidden">0</span>
	   	                      			<span class="product-id hidden"><%=orderProduct.getProductId() %></span>
	   	                      			<span class="date hidden"></span>
	   	                      		</div>
	   	                      	<% 
										}
	   	                      		} %>
	   	                      </td>
		                      <td class="center">
		                      	<ul class="buttonlist">
									<li><button class="stdbtn btn_yellow" id="check" value="1">Đã giao</button></li>
								</ul>
		                      </td>	                      
		                  </tr>
		                  <% } %>                                      
	                   </tbody>
	                </table>
				</form>
				<br>
				<div class="order-detail-button">
					<ul class="buttonlist">
						<!-- <li><button class="stdbtn btn_yellow" id="check" value="1">Đã giao</button></li> -->					
						<li><button class="stdbtn btn_red" id="check" value="2">Khách hủy</button></li>
						<li>
							<button class="stdbtn btn_lime" id="check" value="3">Khách hẹn lại</button>
							<div class="form-date">
								<input name="date_return" class="date-return" />
							</div>
						</li>
						<li><button class="stdbtn btn_orange" id="check" value="4">Hết hàng</button></li>
						<li><button class="stdbtn btn_blue" id="check" value="5">Không liên lạc được</button></li>
						<li><button class="stdbtn btn_blue" id="check" value="6">Người khác giao</button></li>
						<li><button class="stdbtn btn_blue" id="check" value="7">Không giao được</button></li>
					</ul>
				</div>
				<br />
			</div>
			<br clear="all">
			
			<div id="form-preview-order">
				<form method="post" action="/admin/coordina/return/" class="stdform stdform2">
					<input type="hidden" class="smallinput" name="action" value="saveReturn">
					<input type="hidden" class="smallinput" name="listOrder" id="listOrder">
					<input type="hidden" class="smallinput" name="coordinaId" value="<%=coordinaModel.getId() %>">
					
					<div class="contenttitle">
						<h2 class="form">
							<span>Hiển thị giao nhận đã giao</span>
						</h2>
					</div>
					<table cellspacing="0" cellpadding="0" border="0" class="stdtable stdtablecb" id="list-order-preview">				
	                    <colgroup>
		                        <col class="con0">
		                        <col class="con1">
		                        <col class="con0">
	                    </colgroup>
	                    <thead>
	                        <tr>
	                        	<th class="head0">STT</th>
	                            <th class="head1">Mã đơn hàng</th>
	                            <th class="head0">Phiếu / Sản phẩm</th>
	                            <th class="head1">Khách hàng</th>	        
	                            <th class="head0">Địa chỉ</th>                                               
	                            <th class="head1">Điện thoại</th>	
	                            <th class="head0">Số lượng</th>	                           
	                            <th class="head1">Đã giao</th>
	                            <th class="head0">Giá trị đơn hàng</th>
	                            <th class="head1">Tổng tiền</th>                         
	                        </tr>
	                    </thead>
	                    <tbody>
	                      <% for (int i = 0; i < listOrder.size(); i++) { %>                             
		                  <tr>
		                      <td class="center"><%=i+1 %></td>
		                      <td align="center"><%=listOrder.get(i).getOrderId() %></td>
		                      <td align="left">
		                      	<%
		                    		List<String> listOrderProduct = listOrder.get(i).getListOrderProduct();
									for (String stringOrderProduct : listOrderProduct) {
										OrderProductModel orderProduct = new OrderProductModel();
										orderProduct.getValueFromString(stringOrderProduct);
										if(orderProduct.getQuantity()>0)
										{
											out.print("["+orderProduct.getProductId()+"]");
											out.print(orderProduct.getName()+" ["+orderProduct.getQuantity()+"]");
											out.print("<br \\/>");
										}
									}
		                    	%>
		                      </td>
	   	                      <td class="center"><%=listOrder.get(i).getShipName() %></td>
	   	                      <td align="left"><%=listOrder.get(i).getShipAddressFull() %></td>   
	   	                      <td class="center"><%=listOrder.get(i).getShipPhoneNumber() %></td>	           
	   	                      <td class="center">
	   	                      	<%=listOrder.get(i).getQuantity() %>
	   	                      </td>
	   	                      <td class="center">
	   	                      	<% 
	   	                     		for (String stringOrderProduct : listOrderProduct) {
		   	                     		OrderProductModel orderProduct = new OrderProductModel();
										orderProduct.getValueFromString(stringOrderProduct);
										if(orderProduct.getQuantity()>0)
										{
	   	                      	%>   	                     
	   	                      		<div class="change-number">
	   	                      			<span class="number"><%=orderProduct.getQuantity() %></span>
	   	                      		</div>
	   	                      	<% 
										}
	   	                      		} %>
	   	                      </td>
	   	                      <td class="center">
	   	                      	<%=listOrder.get(i).getUnitPrice()%>
	   	                      	<span class="money hidden"><%=listOrder.get(i).getUnitPrice()%></span>
	   	                      </td>
	   	                      <td class="center totalMoney"></td>
		                  </tr>
		                  <% } %>                                      
	                   </tbody>
	                </table>
	                <div id="dyntable_paginate" class="dataTables_paginate paging_full_numbers">	 
		            	<b>Tổng giá trị thanh toán : <span id="totalAllMoney"></span></b>
		            </div>
					
					<p class="stdformbutton">
						<button class="submit radius2">Hoàn thành</button>
					</p>
				</form>
			</div>
		</div>
		<!--content-->
	</div>
	<!--maincontentinner-->

	<jsp:include page="/admin/elements/copyright.jsp">
		<jsp:param name="language" value="1" />
	</jsp:include>

</div>
<jsp:include page="/admin/layouts/footer.jsp">
	<jsp:param name="language" value="1" />
</jsp:include>